package com.mind.adjust.service.impl;

import com.mind.common.utils.StringUtils;
import com.mind.customer.mapper.AjCheckResultMapper;
import com.mind.system.domain.AjAttachResult;
import com.mind.adjust.service.AjAttachResultService;
import com.mind.system.mapper.AttachResultMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;


/**
 * 附件结果(AjAttachResult)表服务实现类
 *
 * @author makejava
 * @since 2024-08-12 11:42:43
 */
@Service("attachResultService")
public class AjAttachResultServiceImpl implements AjAttachResultService {
    @Autowired
    private AttachResultMapper attachResultMapper;


    @Resource
    private AjCheckResultMapper checkResultMapper;

    /**
     * 查询附件结果信息集合
     * 
     * @param attachResult 附件结果信息
     * @return 附件结果信息集合
     */
    @Override
    public List<AjAttachResult> selectAttachResultList(AjAttachResult attachResult)
    {
        return attachResultMapper.selectAttachResultList(attachResult);
    }

    /**
     * 通过附件结果ID查询附件结果信息
     * 
     * @param attachResultId 附件结果ID
     * @return 角色对象信息
     */
    @Override
    public AjAttachResult selectAttachResultById(Long attachResultId)
    {
        return attachResultMapper.selectAttachResultById(attachResultId);
    }

    /**
     * 删除附件结果信息
     * 
     * @param attachResultId 附件结果ID
     * @return 结果
     */
    @Override
    public int deleteAttachResultById(Long attachResultId)
    {
        return attachResultMapper.deleteAttachResultById(attachResultId);
    }

    /**
     * 批量删除附件结果信息
     * 
     * @param attachResultIds 需要删除的附件结果ID
     * @return 结果
     */
    @Override
    public int deleteAttachResultByIds(Long[] attachResultIds)
    {
        return attachResultMapper.deleteAttachResultByIds(attachResultIds);
    }

    /**
     * 新增保存附件结果信息
     * 
     * @param attachResult 附件结果信息
     * @return 结果
     */
    @Override
    public int insertAttachResult(AjAttachResult attachResult)
    {
        return attachResultMapper.insertAttachResult(attachResult);
    }

    /**
     * 修改保存附件结果信息
     * 
     * @param attachResult 附件结果信息
     * @return 结果
     */
    @Override
    public int updateAttachResult(AjAttachResult attachResult)
    {
        return attachResultMapper.updateAttachResult(attachResult);
    }
    
    /**
     * 批量插入
     *
     * @param attachResultList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjAttachResult> attachResultList) {
        int size = 0;
//        for(AjAttachResult attachResult: attachResultList) {
//            if (attachResultMapper.selectAttachResultByName(attachResult.getName()) == null){
//                attachResultMapper.insertAttachResult(attachResult);
//                size ++;
//            }
//        }
        return size;
    }

    @Override
    public List<AjAttachResult> attachList(String ticketId, Integer version) {
        if(StringUtils.isNull(version)) {
            version = checkResultMapper.selectLastVersion(ticketId);
        }
        return attachResultMapper.selectAttachList(ticketId, version);
    }
}
